<?php
session_start();
imgVerification();
function imgVerification()
{
    $images = ['pic0' => '猫', 'pic1' => '狗', 'pic2' => '羊', 'pic3' => '兔'];

    $index                = rand(0, 3);
    $value                = $images['pic' . $index];
    $_SESSION['img_code'] = $value;

    $filename = dirname(__FILE__) . '/pic' . $index . '.jpg';
    $contents = file_get_contents($filename);

    header('content-type: image/jpg');
    echo $contents;
}
